package com.htthorizon.system.api.factory;

import com.htthorizon.common.core.domain.R;
import com.htthorizon.system.api.RemoteFileService;
import com.htthorizon.system.api.RemoteModelService;
import com.htthorizon.system.api.domain.Config;
import com.htthorizon.system.api.domain.SysFile;
import com.htthorizon.system.api.model.ModelInfoReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

/**
 * 模型服务降级处理
 *
 * @author mark
 */
@Component
public class RemoteModelFallbackFactory implements FallbackFactory<RemoteModelService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteModelFallbackFactory.class);

    @Override
    public RemoteModelService create(Throwable throwable)
    {
        log.error("模型服务调用失败:{}", throwable.getMessage());

        return new RemoteModelService()
        {
            @Override
            public R<Boolean> saveMeta(ModelInfoReq modelInfoReq)
            {
                return R.fail("保存模型的元数据失败:" + throwable.getMessage());
            }

            @Override
            public R get() {
                return null;
            }

            @Override
            public R edit(Config config) {
                return null;
            }
        };
    }
}
